import React, { Component } from "react";

export default class App extends Component {
  state = {
    list: [
      { id: "001", name: "mikaisa" },
      { id: "002", name: "xiaoming" },
      { id: "003", name: "xiaohong" },
    ],
  };

  render() {
    return (
      <div>
        <ul>
          {/* 为了列表的复用和重排，设置key值，提高性能。测试的时候可以使用index当做key值，但是真实开发中一般数据都会有唯一标识id，设置为item.id即可 */}
          {this.state.list.map((item, index) => (
            <li key={item.id}>
              {item.name}--{index}
            </li>
          ))}
        </ul>
      </div>
    );
  }
}
